#pragma once

#include "core/log_entry.hpp"
#include <memory>
#include <string>
#include <nlohmann/json.hpp>
#include <fmt/core.h>

// ILogger 接口定义了日志记录器的所有公共行为
class ILogger {
public:
    virtual ~ILogger() = default;

    virtual void setLevel(LogLevel level) = 0;
    virtual bool shouldLog(LogLevel level) const = 0;
    virtual std::string getFormatterType() = 0;

    virtual void log(LogLevel level, const std::string& message, const nlohmann::json& context = nlohmann::json()) = 0;

    // 便利方法
    virtual void trace(const std::string& message, const nlohmann::json& context = nlohmann::json()) = 0;
    virtual void debug(const std::string& message, const nlohmann::json& context = nlohmann::json()) = 0;
    virtual void info(const std::string& message, const nlohmann::json& context = nlohmann::json()) = 0;
    virtual void warn(const std::string& message, const nlohmann::json& context = nlohmann::json()) = 0;
    virtual void error(const std::string& message, const nlohmann::json& context = nlohmann::json()) = 0;
    virtual void critical(const std::string& message, const nlohmann::json& context = nlohmann::json()) = 0;

/*    // 模板特化接口*/
    /*template<typename... Args>*/
    /*void trace(fmt::format_string<Args...> fmt, Args&&... args) {*/
        /*log(LogLevel::Trace, fmt::format(fmt, std::forward<Args>(args)...));*/
    /*}*/
    
    /*template<typename... Args>*/
    /*void debug(fmt::format_string<Args...> fmt, Args&&... args) {*/
        /*log(LogLevel::Debug, fmt::format(fmt, std::forward<Args>(args)...));*/
    /*}   */

    /*template<typename... Args>*/
    /*void info(fmt::format_string<Args...> fmt, Args&&... args) {*/
        /*log(LogLevel::Info, fmt::format(fmt, std::forward<Args>(args)...));*/
    /*}   */

    /*template<typename... Args>*/
    /*void warn(fmt::format_string<Args...> fmt, Args&&... args) {*/
        /*log(LogLevel::Warn, fmt::format(fmt, std::forward<Args>(args)...));*/
    /*}*/

    /*template<typename... Args>*/
    /*void error(fmt::format_string<Args...> fmt, Args&&... args) {*/
        /*log(LogLevel::Error, fmt::format(fmt, std::forward<Args>(args)...));*/
    /*}*/

    /*template<typename... Args>*/
    /*void critical(fmt::format_string<Args...> fmt, Args&&... args) {*/
        /*log(LogLevel::Critical, fmt::format(fmt, std::forward<Args>(args)...));*/
    /*}   */


    // 控制方法
    virtual void flush() = 0;
    virtual void dumpBacktrace() = 0;
    virtual void enableBacktrace(size_t size) = 0;
};
